package com.example.servlet.requestredirection;

import javax.servlet.*;
import javax.servlet.http.*;
import java.io.IOException;
//重定向
//地址栏发声变化
//两次请求
//不共享Request
public class Servlet3 extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        System.out.println("类似于已废弃的servlet");
        //设置重定向状态码
//        response.setStatus(302);
        //设置地址
//        response.setHeader("Location","http://localhost:8080/servlet/servlet4");

        //简写重定向
    response.sendRedirect("http://localhost:8080/servlet/servlet4");
    }


    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

    }
}
